package com.wangx1n.boobey.controller;

import com.google.gson.Gson;
import com.wangx1n.boobey.entity.pk.Problem;
import com.wangx1n.boobey.service.WordService;
import com.wangx1n.boobey.util.ApiResult;
import com.wangx1n.boobey.util.WordUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangxin
 * @create 2020-06-12 17:12
 */
@RestController
public class WordController {
    @Autowired
    WordService wordService;
    @RequestMapping(value = "/getword")
    public String getword(@Param(value = "word") String word){
        if(word==null){
            return wordService.getData("");
        }
        return wordService.getData(word);
    }
    //返回测试单词
    @RequestMapping(value = "/gettestword")
    public String getword(){
        Problem problem = new Problem();
        Gson gson = new Gson();
        problem = WordUtil.makeProblem(1);
        return gson.toJson(ApiResult.success(problem,0));
    }

}
